package cn.gson.tj_springboot.controler.PreSalesController;

import cn.gson.tj_springboot.model.pojos.Demand;
import cn.gson.tj_springboot.model.service.PreSalesService.DemandService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class DemandController {
    @Autowired
    DemandService demandService;

    @RequestMapping("/login")
    @ResponseBody
    public String login(){
        return "hello";
    }

    @RequestMapping("/demand")
    @ResponseBody
    public Map<String,Object> findAllDemand(Integer page,Integer size){
        Page<Object> objects = PageHelper.startPage(page, size);
        List<Demand> demandList=demandService.findAllDemand();
        Map<String,Object> map=new HashMap<>();
        map.put("total",objects.getTotal());
        map.put("rows",demandList);
        return map;
    }
}

